{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b5c05367-af7a-4ed1-b6b7-3d871a73432d",
   "metadata": {},
   "source": [
    "<center><img src=\"./image/CLBLOGO.jpg\" alt=\"创乐博\" style=\"width: 300px;\"/></center>\n",
    "\n",
    "# 16.模拟霍尔传感器实验\n",
    "\n",
    "@－－－－湖南创乐博智能科技有限公司－－－－<br>\n",
    "@  文件名：16.模拟霍尔传感器实验.py <br>\n",
    "@  版本：V2.0 <br>\n",
    "@  author: zhulin<br>\n",
    "@  说明：模拟霍尔传感器实验\n",
    "模拟霍尔传感器实验，通过GPIOZero库自带的MCP3008 10位模数转换库直接控制，采集到模拟霍尔传感器的模拟值，从而判断磁性物质！！！<br>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f5f58331-df2f-409c-b08b-1401a5100a80",
   "metadata": {},
   "source": [
    "## 1.导入必要的库文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "83db1301-789c-4820-af1b-3a55d0b03465",
   "metadata": {},
   "outputs": [],
   "source": [
    "from gpiozero import PWMLED, MCP3008\n",
    "from gpiozero.tools import absoluted, scaled\n",
    "from signal import pause\n",
    "from time import sleep"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf81ed90-ea51-4447-b522-85494d089b54",
   "metadata": {},
   "source": [
    "## 2.定义使用通道"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "20561d89-e334-41e0-9358-07f9b385ffdd",
   "metadata": {},
   "outputs": [],
   "source": [
    "makerobo_hall = MCP3008(channel=0) # 定义电位器获取ADC值通道"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f61388b-5a73-43b3-88c7-3167f1bd68f5",
   "metadata": {},
   "source": [
    "## 3.定义打印"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "81b1514f-5d90-42c4-826e-17124bd69257",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 打印出磁场的信息\n",
    "def makerobo_Print(x):\n",
    "\tif x == 0:    #  没有磁场\n",
    "\t\tprint ('')\n",
    "\t\tprint ('*************')\n",
    "\t\tprint ('* No Magnet *')\n",
    "\t\tprint ('*************')\n",
    "\t\tprint ('')\n",
    "\tif x == 1:    #  磁场为南\n",
    "\t\tprint ('')\n",
    "\t\tprint ('****************')\n",
    "\t\tprint ('* Magnet North *')\n",
    "\t\tprint ('****************')\n",
    "\t\tprint ('')\n",
    "\tif x == -1:   # 磁场为北\n",
    "\t\tprint ('')\n",
    "\t\tprint ('****************')\n",
    "\t\tprint ('* Magnet South *')\n",
    "\t\tprint ('****************')\n",
    "\t\tprint ('')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9e8dc3b8-858e-4434-8062-f44edb629870",
   "metadata": {},
   "source": [
    "## 4.循环函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "660f4219-a6c7-4511-a918-14be8f04e8ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "def MAP(x, in_min, in_max, out_min, out_max):\n",
    "    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min\n",
    "\n",
    "def makerobo_loop():\n",
    "    makerobo_status = 0 # 给状态变量赋0值\n",
    "    while True:  # 无限循环\n",
    "        makerobo_res = round(makerobo_hall.value * 1000)  # 获取AIN0 的模拟量值，并扩大1000倍\n",
    "        makerobo_res = round(MAP(makerobo_res,0,1000,0,255))\n",
    "        print ('Current intensity of magnetic field : ', makerobo_res) # 打印出磁场的电流强度值\n",
    "        if makerobo_res - 133 < 5 and makerobo_res - 133 > -5: # 判断磁场强度范围\n",
    "            makerobo_tmp = 0    #  没有磁场\n",
    "        if makerobo_res < 128:  # 磁场强度为北\n",
    "            makerobo_tmp = -1\n",
    "        if makerobo_res > 138:  # 磁场强度为南\n",
    "            makerobo_tmp = 1\n",
    "        if makerobo_tmp != makerobo_status: # 磁场发生改变\n",
    "            makerobo_Print(makerobo_tmp) # 调用打印出磁场的信息\n",
    "            makerobo_status = makerobo_tmp # 把当前状态值设置为比较状态值，避免重复打印；\n",
    "        sleep(0.2) # 延时200ms "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "04b01200-b8f4-4906-9fef-ee5921375822",
   "metadata": {},
   "source": [
    "## 5.主程序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "45e18609-d482-4008-9b7f-64ee3599f522",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current intensity of magnetic field :  255\n",
      "\n",
      "****************\n",
      "* Magnet North *\n",
      "****************\n",
      "\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  2\n",
      "\n",
      "****************\n",
      "* Magnet South *\n",
      "****************\n",
      "\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  255\n",
      "\n",
      "****************\n",
      "* Magnet North *\n",
      "****************\n",
      "\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  2\n",
      "\n",
      "****************\n",
      "* Magnet South *\n",
      "****************\n",
      "\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  2\n",
      "Current intensity of magnetic field :  252\n",
      "\n",
      "****************\n",
      "* Magnet North *\n",
      "****************\n",
      "\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n",
      "Current intensity of magnetic field :  255\n"
     ]
    }
   ],
   "source": [
    "# 程序入口\n",
    "if __name__ == '__main__':\t\t\n",
    "\ttry:\n",
    "\t\tmakerobo_loop() # 调用循环函数\n",
    "\texcept KeyboardInterrupt:  \t# 当按下Ctrl+C时，将执行destroy()子程序。\n",
    "\t\tdestroy()   # 调用释放函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb7e12fb-6560-491a-b0cb-66866ee54b37",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
